(function () {
    var gameUrl = '/game/ajax_game_list/',
        key = utils.getParams(1),
        type = utils.getParams(2),
        paramType;

    if(type === 'cate' || type === 'tag'){
        gameUrl = '/game/ajax_game_list/' + key;
    }else if(key === 'mobile'){
        paramType = 1;
    }else if(key === 'h5'){
        paramType = 2;
    }

    //必须使用data.attr
    var template =
        `<li class="common-game-item">
            <a class="common-game-avatar" href="/game/detail/{% data.id %}" target="_blank">
                <img data-original="{% data.img %}">
            </a>
            <div class="common-game-detail">
              <div class="common-game-info">
                <div class="common-game-name">
                  <a class="ellipse" href="/game/detail/{% data.id %}" target="_blank">{% data.name %}</a>
                  {% if( data.is_android ){ %}
                    <span class="iconfont icon-anzhuo"></span>
                  {% } %}
                  {% if( data.is_ios ){ %}
                    <span class="iconfont icon-iOS"></span>
                  {% } %}
                </div>
                <div class="common-game-intro ellipse">
                    <div class="game-cate">{% data.cate_id %}</div>
                    <div>{% data.nums %}人关注</div>
                </div>
                <div class="common-game-additional common-game-tags">
                     {% for(var i = 0; i < data.tags.length; i++ ) { %}
                        <span> {% data.tags[i] %} </span>
                     {% } %}
                </div>
              </div>
            </div>
        </li>`;


    //创建点击加载更多功能
    var loadGameList = new LoadData({
        btn: '#getMoreBtn',
        lists: '#gameTotalList',
        listType: 'game',
        url: gameUrl,
        page: 2,
        paramType: paramType,
        template: template,
        method: 'append',
        loadingAnim: true,
        loadingAnimDom: '.loading-container',
        handleFn: {
            'cate_id': utils.setDataItem.bind(utils),
            'tags': utils.setDataItem.bind(utils)
        },
        afterRender: function () {
            $("img").lazyload({
                effect: "fadeIn",
                effectspeed: 1500
            });
        }
    });

})();